<?php
/**
 * Created by PhpStorm.
 * User: dongkai
 * Date: 2018/3/18
 * Time: 下午9:06
 */
namespace App\Model\Protobuf;

use App\Model\Model;
use AutoMsg\FinanceInfo;
use AutoMsg\FriendInfo;
use AutoMsg\LoadAchievement;
use AutoMsg\LoadDepartMentInfo;
use AutoMsg\LoadFinanceLogInfo;
use AutoMsg\LoadLeaderInfo;
use AutoMsg\LoansInfo;
use AutoMsg\SavingInfo;

/**
 * Class ProtoCommon proto公共类
 * @package App\Model\Protobuf
 */
class ProtoCommon extends Model
{
    function repeated($items){
        $arr = [];
        foreach ($items as $k => $item) {
            $arr[$k] = $item;
        }
        return $arr;
    }

    /**
     * 部门
     * @param $obj
     * @return mixed
     */
    function LoadDepartMentInfo($obj){
        $pt = new LoadDepartMentInfo();
        $FinanceInfo = $pt->getFinanceInfo();
        $InvestmentInfo = $pt->getInvestmentInfo();
        $MarketInfo = $pt->getMarketInfo();
        $PersonnelInfo = $pt->getPersonnelInfo();
        $arr['FinanceInfo'] = $FinanceInfo;
        $arr['InvestmentInfo'] = $InvestmentInfo;
        $arr['MarketInfo'] = $MarketInfo;
        $arr['PersonnelInfo'] = $PersonnelInfo;
        return $arr;
    }
    function LoadFinanceLogInfo($items){
        foreach ($items as $k =>$item){
            $Time = $item->getTime();
            $EventName = $item->getEventName();
            $EventType = $item->getEventType();
            $MoneyType = $item->getMoneyType();
            $Count = $item->getCount();
            $AorD = $item->getAorD();
            $arr[$k]['Time'] = $Time;
            $arr[$k]['EventName'] = $EventName;
            $arr[$k]['MoneyType'] = $MoneyType;
            $arr[$k]['Count'] = $Count;
            $arr[$k]['AorD'] = $AorD;
        }
        return $arr;
    }
    function FriendInfo($items){
//        $item = new FriendInfo();
        $arr = [];
        foreach ($items as $k=>$item) {
            $Level = $item->getLevel();
            $Name = $item->getName();
            $SocialStatus = $item->getSocialStatus();
            $Icon = $item->getIcon();
            $RoleId = $item->getRoleId();
            $AddTime = $item->getAddTime();
            $ApplyTime = $item->getApplyTime();
            $DigCount = $item->getDigCount();
            $FriendValue = $item->getFriendValue();
            $HireTime = $item->getHireTime();
            $OnlineTime = $item->getOnlineTime();
            $ShopId = $item->getShopId();
            $Status = $item->getStatus();
            $VIP = $item->getVIP();
            $WorkCompany = $item->getWorkCompany();
            $arr[$k]['Level'] = $Level;
            $arr[$k]['Name'] = $Name;
            $arr[$k]['SocialStatus'] = $SocialStatus;
            $arr[$k]['Icon'] = $Icon;
            $arr[$k]['RoleId'] = $RoleId;
            $arr[$k]['AddTime'] = $AddTime;
            $arr[$k]['ApplyTime'] = $ApplyTime;
            $arr[$k]['DigCount'] = $DigCount;
            $arr[$k]['FriendValue'] = $FriendValue;
            $arr[$k]['HireTime'] = $HireTime;
            $arr[$k]['OnlineTime'] = $OnlineTime;
            $arr[$k]['ShopId'] = $ShopId;
            $arr[$k]['HireTime'] = $HireTime;
            $arr[$k]['HireTime'] = $HireTime;
        }
        return $arr;
    }
    function SavingInfo($items){
        foreach ($items as $k =>$item){
            $Id = $item->getId();
            $GoldCount = $item->getGoldCount();
            $Earnings = $item->getEarnings();
            $GoldType = $item->getGoldType();
            $LoadingTime = $item->getLoadingTime();
            $SavingInst = $item->getSavingInst();
            $SavingTime = $item->getSavingTime();
            $SavingType = $item->getSavingType();
            $TimeLimit = $item->getTimeLimit();
            $arr[$k]['Id'] = $Id;
            $arr[$k]['GoldCount'] = $GoldCount;
            $arr[$k]['Earnings'] = $Earnings;
            $arr[$k]['GoldType'] = $GoldType;
            $arr[$k]['LoadingTime'] = $LoadingTime;
            $arr[$k]['SavingInst'] = $SavingInst;
            $arr[$k]['SavingTime'] = $SavingTime;
            $arr[$k]['SavingType'] = $SavingType;
            $arr[$k]['TimeLimit'] = $TimeLimit;
        }
        return $arr;
    }
    function LoadLeaderInfo($obj){
        $LoadLeaderInfo = new LoadLeaderInfo();
        $LoadLeaderInfo->mergeFrom($obj);
        $LeaderTime = $LoadLeaderInfo->getLeaderTime();
        $ShopLeader = $LoadLeaderInfo->getShopLeader();
        $arr['LeaderTime'] = $LeaderTime;
        $arr['ShopLeader'] = $ShopLeader;
        return $arr;
    }
    function LoansInfo(){
        echo 123;
        $LoansInfo = new LoansInfo();
        $GoldType = $LoansInfo->getGoldType();
        $GoldCount = $LoansInfo->getGoldCount();
        $Id = $LoansInfo->getId();
        $WhetherTheLoan = $LoansInfo->getWhetherTheLoan();
        $Day = $LoansInfo->getDay();
        $LoansTime = $LoansInfo->getLoansTime();

        $arr['GoldType'] = $GoldType;
        $arr['GoldCount'] = $GoldCount;
        $arr['Id'] = Id;
        $arr['WhetherTheLoan'] = $WhetherTheLoan;
        $arr['Day'] = $Day;
        $arr['LoansTime'] = $LoansTime;
        return $arr;
    }

    function LoadAchievement($LoadAchievement){
        $LoadAchievement = new LoadAchievement();
        foreach ($LoadAchievement as $item) {
            $LoadAchievement->getGets();
            $LoadAchievement->getRewards();
        }
    }
}